﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Dukous.Search;
using Celine.Domain.Customers;

namespace Celine.BizService.Searcher
{
    /// <summary>
    /// 
    /// </summary>
    public class CustomerSearcher : ISearcher
    {
        public ISearchSupport<Customer> SearchSupport { get; set; }

        public ISearchResult Search(ISearchContext context)
        {
            int totalCount = 0;
            IList<Customer> customers = this.SearchSupport.SelectBySearch(context, out totalCount);

            SearchResult result = new SearchResult(context, totalCount);

            foreach (var item in customers)
            {
                result.AddItem(new PropertySearchResultItem(item).Id<long>(item.Id));
            }

            return result;
        }
    }
}
